/*
 * generate by table-builder.Don't modify it
 */
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using System.Collections.Generic;


namespace CfgTable
{
    public partial class TbCfgHeroSkin
    {
        private readonly Dictionary<int, CfgHeroSkin> _dataMap;
        private readonly List<CfgHeroSkin> _dataList;


        public TbCfgHeroSkin(ByteBuf _buf)
        {
            //first read common data
            _TbCommonHeroSkin _commonData = null;
            var commonSize = _buf.ReadSize();
            if (commonSize > 0)
            {
                _commonData = new _TbCommonHeroSkin(_buf);
            }

            //then read row data
            var size = _buf.ReadSize();
            _dataMap = new Dictionary<int, CfgHeroSkin>(size * 3 / 2);
            _dataList = new List<CfgHeroSkin>(size);

            for (int i = 0; i < size; i++)
            {
                CfgHeroSkin _v;
                _v = CfgHeroSkin.DeserializeCfgHeroSkin(_buf, _commonData);
                _dataList.Add(_v);
                _dataMap.Add(_v.Id, _v);
            }

            // read extra fields 

            PostInit();
        }

        public IReadOnlyDictionary<int, CfgHeroSkin> DataMap => _dataMap;
        public IReadOnlyList<CfgHeroSkin> DataList => _dataList;

        public CfgHeroSkin Get(int key)
        {
            if (_dataMap.TryGetValue(key, out var v))
            {
                return v;
            }
            IQIGame.Onigao.Framework.LogGame.LogError("[TbCfgHeroSkin] config not found,id:" + key.ToString());

            return null;
        }

        public CfgHeroSkin GetWithoutError(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;

        /// <summary>
        /// table data file
        /// </summary>
        public static string TableFileName { get; } = "heroskin";

        /// <summary>
        /// load table function
        /// </summary>
        public static TbCfgHeroSkin LoadFromFunc(System.Func<string, ByteBuf> loadFunc)
        {
            return new TbCfgHeroSkin(loadFunc(TableFileName));
        }

        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();

    }

    public partial class CfgHeroSkin
    {
        private CfgHeroSkin(ByteBuf _buf, _TbCommonHeroSkin _commonData)
        {
            Id = _buf.ReadInt();
            Name = TableCenter.GetI18NText(_buf.ReadInt());
            Desc = TableCenter.GetI18NText(_buf.ReadInt());
            IsHide = _buf.ReadBool();
            Duration = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; Transformation = _commonData._field0[dataIndex]; }
            LevelEntity = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; BattleEntityAsset = _commonData._field1[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; WidgetEntityAsset = _commonData._field2[dataIndex]; }
            DefaultSmallPet = _buf.ReadInt();
            SmallPetPoint = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; BattleHeadIcon = _commonData._field3[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; BattleStateHeadIcon = _commonData._field4[dataIndex]; }
            GainWay = TableCenter.GetI18NText(_buf.ReadInt());
            { int dataIndex = _buf.ReadInt() - 1; HeroHeadImage = _commonData._field5[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; HeroHalfBodyImage = _commonData._field6[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; HeroFormationImage = _commonData._field7[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; BodyPrefab = _commonData._field8[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; UIEntityAsset = _commonData._field9[dataIndex]; }
            UnlockCV = _buf.ReadInt();
            BuyMallItemId = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; Channels = _commonData._field10[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; InvisibleChannels = _commonData._field11[dataIndex]; }
            NoticeId = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; DressUnlockShow = _commonData._field12[dataIndex]; }

            PostInit();
        }

        internal static CfgHeroSkin DeserializeCfgHeroSkin(ByteBuf _buf, _TbCommonHeroSkin _commonData)
        {
            return new CfgHeroSkin(_buf, _commonData);
        }

        /// <summary>
        /// major key
        /// </summary>
        public int Id { get; private set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; private set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Desc { get; private set; }
        /// <summary>
        /// 是否默认隐藏（0不隐藏，1隐藏）
        /// </summary>
        public bool IsHide { get; private set; }
        /// <summary>
        /// 有效时长(秒)
        /// </summary>
        public int Duration { get; private set; }
        /// <summary>
        /// 溢出后转换道具
        /// </summary>
        public IReadOnlyList<int> Transformation { get; private set; }
        /// <summary>
        /// 关卡实体id
        /// </summary>
        public int LevelEntity { get; private set; }
        /// <summary>
        /// 实体资源名
        /// </summary>
        public string BattleEntityAsset { get; private set; }
        /// <summary>
        /// 固件资源名
        /// </summary>
        public string WidgetEntityAsset { get; private set; }
        /// <summary>
        /// 默认小宠物
        /// </summary>
        public int DefaultSmallPet { get; private set; }
        /// <summary>
        /// 小宠物挂点
        /// </summary>
        public int SmallPetPoint { get; private set; }
        /// <summary>
        /// 行动条头像(Assets\Res\05_Images\Sprite\Icon_BattleHead)
        /// </summary>
        public string BattleHeadIcon { get; private set; }
        /// <summary>
        /// 状态栏头像(Assets\Res\05_Images\Sprite\Icon_BattleHead)
        /// </summary>
        public string BattleStateHeadIcon { get; private set; }
        /// <summary>
        /// 获取途径
        /// </summary>
        public string GainWay { get; private set; }
        /// <summary>
        /// 英雄UI方形头像图片资源路径（Assets\Res\05_Images\Sprite\Icon_HeroHead）
        /// </summary>
        public string HeroHeadImage { get; private set; }
        /// <summary>
        /// 英雄列表半身像图片资源路径（Assets\Res\05_Images\Texture\UIHeroRes\UIHeroHalfBody）
        /// </summary>
        public string HeroHalfBodyImage { get; private set; }
        /// <summary>
        /// 英雄编队界面图片资源路径（Assets\Res\05_Images\Texture\UIHeroRes\UIHeroFormationHead）
        /// </summary>
        public string HeroFormationImage { get; private set; }
        /// <summary>
        /// 时装立绘png预设资源路径（Assets\Res\03_Prefabs\UI\HeroSkinPrefab）
        /// </summary>
        public string BodyPrefab { get; private set; }
        /// <summary>
        /// UI实体资源名（Assets\Res\03_Prefabs\UI\HeroModel3D）
        /// </summary>
        public string UIEntityAsset { get; private set; }
        /// <summary>
        /// 解锁时语音
        /// </summary>
        public int UnlockCV { get; private set; }
        /// <summary>
        /// 购买获取时装跳转商城ID
        /// </summary>
        public int BuyMallItemId { get; private set; }
        /// <summary>
        /// 可见平台ID(填写后，仅所填写的渠道平台能看见）
        /// </summary>
        public IReadOnlyList<string> Channels { get; private set; }
        /// <summary>
        /// 不可见平台ID（填写后，仅所填写的平台不可见）
        /// </summary>
        public IReadOnlyList<string> InvisibleChannels { get; private set; }
        /// <summary>
        /// 提示ID
        /// </summary>
        public int NoticeId { get; private set; }
        /// <summary>
        /// 时装解锁时所用的展示预设
        /// </summary>
        public string DressUnlockShow { get; private set; }

        /// <summary>
        /// HeroHalfBodyImage 资源全路径
        /// </summary>
        public string HeroHalfBodyImage_fullPath => $"Res/05_Images/Texture/UIHeroRes/UIHeroHalfBody/{HeroHalfBodyImage}";
        /// <summary>
        /// BodyPrefab 资源全路径
        /// </summary>
        public string BodyPrefab_fullPath => $"Res/03_Prefabs/UI/HeroSkinPrefab/{BodyPrefab}";
        /// <summary>
        /// UIEntityAsset 资源全路径
        /// </summary>
        public string UIEntityAsset_fullPath => $"Res/03_Prefabs/UI/HeroModel3D/{UIEntityAsset}";
        /// <summary>
        /// BattleHeadIcon 资源全路径
        /// </summary>
        public string BattleHeadIcon_fullPath => $"Res/05_Images/Sprite/Icon_BattleHead/{BattleHeadIcon}";
        /// <summary>
        /// BattleStateHeadIcon 资源全路径
        /// </summary>
        public string BattleStateHeadIcon_fullPath => $"Res/05_Images/Sprite/Icon_BattleHead/{BattleStateHeadIcon}";
        /// <summary>
        /// BattleEntityAsset 资源全路径
        /// </summary>
        public string BattleEntityAsset_fullPath => $"Res/02_Character/{BattleEntityAsset}/mb_{BattleEntityAsset}.prefab";
        /// <summary>
        /// HeroHeadImage 资源全路径
        /// </summary>
        public string HeroHeadImage_fullPath => $"Res/05_Images/Sprite/Icon_HeroHead/{HeroHeadImage}";
        /// <summary>
        /// HeroFormationImage 资源全路径
        /// </summary>
        public string HeroFormationImage_fullPath => $"Res/05_Images/Texture/UIHeroRes/UIHeroFormationHead/{HeroFormationImage}";

        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();
    }

    /// <summary>
    /// internal common data.Optimize memory
    /// </summary>
    internal class _TbCommonHeroSkin
    {

        internal IReadOnlyList<IReadOnlyList<int>> _field0 { get; private set; }
        internal IReadOnlyList<string> _field1 { get; private set; }
        internal IReadOnlyList<string> _field2 { get; private set; }
        internal IReadOnlyList<string> _field3 { get; private set; }
        internal IReadOnlyList<string> _field4 { get; private set; }
        internal IReadOnlyList<string> _field5 { get; private set; }
        internal IReadOnlyList<string> _field6 { get; private set; }
        internal IReadOnlyList<string> _field7 { get; private set; }
        internal IReadOnlyList<string> _field8 { get; private set; }
        internal IReadOnlyList<string> _field9 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<string>> _field10 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<string>> _field11 { get; private set; }
        internal IReadOnlyList<string> _field12 { get; private set; }
        internal _TbCommonHeroSkin(ByteBuf _buf)
        {
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field0 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field1 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field2 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field3 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field4 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field5 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field6 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field7 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field8 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field9 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0][]; _field10 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new string[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ string __v1; __v1 = _buf.ReadString(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0][]; _field11 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new string[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ string __v1; __v1 = _buf.ReadString(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field12 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
        }

    }
}
